#include "zab.h"
#include "zab_communication.h"
#include "test.h"
#include "ae.h"
#include "misc_utils.h"

void test_zab(int id)
{
    NODE_RUNTIME_T* runtime;
    const char* zoo_file = "data/zoo.cfg";
    STRING_T* runtime_file = string_printf("data/node%d/node.cfg", id);
    aeEventLoop* loop = aeCreateEventLoop();
    int rc;

    runtime = zab_load_node_runtime(zoo_file, runtime_file->data);
    rc = zab_init(runtime, loop);
    EXPECT(rc == 1);

    aeMain(loop);

    // finished?
    zab_destroy(runtime, loop);
    aeDeleteEventLoop(loop);
}
